-- ***********************************************
-- * Hymn
-- ***********************************************
--------
function special_hymn()

	Attack.act_aseq(0, "cast")
	local dmgt = Attack.aseq_time(0, "x")
	local count = Attack.act_size(0)

	local n = Attack.cell_count()
	for j=0,n-1 do

		local i = Attack.cell_get(j)
		local dmg_min,dmg_max = text_range_dec(Attack.get_custom_param("damage"))
		local typedmg=Attack.get_custom_param("typedmg")
		local duration=Attack.get_custom_param("duration")

		if Attack.act_enemy(i)
		and not Attack.act_feature(i,"plant,golem,mech") then

			Attack.atom_spawn(i, 0, "effect_hymn", Attack.angleto(i))

			if Attack.act_feature(i,"undead,demon") then

				Attack.atk_set_damage(typedmg,dmg_min,dmg_max)
				common_cell_apply_damage(i,dmgt)
				effect_hymn_attack(i,0,duration)
			else
				Attack.atk_set_damage(typedmg,dmg_min/200,dmg_max/200)
				common_cell_apply_damage(i,dmgt)
			end
  		end
	end
	return true
end

function effect_hymn_attack(target,pause,duration,power)


	if pause==nil then
		pause=0
	end
	if duration==nil then
		duration=tonumber(Logic.obj_par("effect_hymn","duration"))
	else
		duration = tonumber(duration)
	end
	if power==nil then
		power=tonumber(Logic.obj_par("effect_hymn","power"))
	end
	if target==nil then
		target = Attack.get_target()
	end

	Attack.act_del_spell( target, "effect_holy" )
	Attack.act_del_spell( target, "effect_hymn" )
	Attack.act_apply_spell_begin(target, "effect_hymn", duration, false )
	Attack.act_apply_par_spell("attack", 0, -power, 0, duration, false)
 	Attack.act_apply_par_spell("defense", 0, -power, 0, duration, false)
 	Attack.act_apply_par_spell("initiative", 0, -power, 0, duration, false)
	Attack.act_apply_spell_end()
	Attack.act_damage_addlog(target,"add_blog_holy_")
	Attack.atom_spawn(target, pause, "effect_purification",0,true)
	return true
end
--------